package com.example.demo.stream.consumer;

import com.example.demo.stream.annotation.RedisStreamListener;
import com.example.demo.stream.common.DataObject;
import com.example.demo.stream.processor.RedisStreamMessageHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@RedisStreamListener(
        topic = "user_stream",
        consumerGroup = "user_group",
        consumer = "c1",
        consumeThreadMax = 3
)
@Slf4j
public class UserStreamHandler implements RedisStreamMessageHandler<Object> {

    @Override
    public void onMessage(DataObject<Object> message) {
       log.info("用户消息消费：" + message.toString());
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    }
}
